using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Jonathan
{
    public partial class ctrlWorking : UserControl
    {
        private Bitmap m_WaitImage;

        public ctrlWorking ()
        {
            InitializeComponent();
            this.label1.Font = SystemFonts.CaptionFont;
            this._picWait.Paint += new PaintEventHandler(_picWait_Paint);
            this.Load += new EventHandler(ctrlWorking_Load);
        }

        void _picWait_Paint (object sender, PaintEventArgs e)
        {
            ImageAnimator.UpdateFrames();
            Bitmap temp = new Bitmap(this.m_WaitImage, this.m_WaitImage.Width, this.m_WaitImage.Height);
            e.Graphics.Clear(this.BackColor);
            e.Graphics.DrawImage(temp, new Point(0, (this._picWait.Height / 2) - (this.m_WaitImage.Height / 2)));
        }

        void ctrlWorking_Load (object sender, EventArgs e)
        {
            this.m_WaitImage = global::Jonathan.InternalImages.WaitSpinner;
            ImageAnimator.Animate(this.m_WaitImage, new EventHandler(this.Animate));
        }

        private void Animate (object sender, EventArgs e)
        {
            this._picWait.Invalidate();
        }

        public void SetText (string text)
        {
            this.label1.Text = text;
            this.Width = this.label1.Right + 10;
        }
    }
}
